﻿<UserControl x:Class="BillsManager.Views.SupplierAddEditView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:Behaviors="clr-namespace:BillsManager.Views.Behaviors"
             xmlns:ViewModel="clr-namespace:BillsManager.ViewModels;assembly=BillsManager.ViewModels"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Loc="clr-namespace:BillsManager.Localization;assembly=BillsManager.Localization"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             d:DataContext="{d:DesignInstance Type=ViewModel:SupplierAddEditViewModel,
                                              IsDesignTimeCreatable=True}"
             mc:Ignorable="d">

    <UserControl.Resources>
        <!--<ResourceDictionary Source="Dictionaries\Styles.xaml" />-->
        <ResourceDictionary Source="Themes\Themes.xaml" />
    </UserControl.Resources>

    <UserControl.Background>
        <Binding Mode="OneTime" Source="{StaticResource View.Background}" />
    </UserControl.Background>

    <Grid Grid.IsSharedSizeScope="True">
        <Grid.RowDefinitions>
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" SharedSizeGroup="row" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" SharedSizeGroup="row" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="18" />
            <RowDefinition Height="Auto" SharedSizeGroup="row" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" SharedSizeGroup="row" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" SharedSizeGroup="row" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" SharedSizeGroup="row" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="18" />
            <RowDefinition Height="Auto" SharedSizeGroup="row" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" SharedSizeGroup="row" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" SharedSizeGroup="row" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="18" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" SharedSizeGroup="row" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" SharedSizeGroup="row" />
            <RowDefinition Height="{StaticResource View.Region.Spacing.Medium}" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="{StaticResource View.MarginSize}" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="{StaticResource View.MarginSize}" />
            <ColumnDefinition Width="Auto" MinWidth="150" />
            <ColumnDefinition Width="{StaticResource View.MarginSize}" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="{StaticResource View.MarginSize}" />
            <ColumnDefinition Width="Auto" MinWidth="150" />
            <ColumnDefinition Width="{StaticResource View.MarginSize}" />
        </Grid.ColumnDefinitions>

        <!--  Details  -->
        <TextBlock Grid.Row="1"
                   Grid.Column="1"
                   Grid.ColumnSpan="7"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Center"
                   FontWeight="Bold"
                   Text="{Loc:Translate Details}" />

        <TextBlock Grid.Row="3"
                   Grid.Column="1"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Name}" />
        <TextBox Grid.Row="3"
                 Grid.Column="3"
                 Grid.ColumnSpan="5"
                 HorizontalAlignment="Stretch"
                 VerticalAlignment="Center"
                 MaxLines="1"
                 TabIndex="0"
                 Text="{Binding Path=Name,
                                UpdateSourceTrigger=PropertyChanged,
                                ValidatesOnDataErrors=True}" />

        <TextBlock Grid.Row="5"
                   Grid.Column="1"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Notes}" />
        <TextBox Grid.Row="5"
                 Grid.Column="3"
                 Grid.ColumnSpan="5"
                 Height="48"
                 HorizontalAlignment="Stretch"
                 VerticalAlignment="Center"
                 HorizontalScrollBarVisibility="Disabled"
                 TabIndex="1"
                 Text="{Binding Path=Notes,
                                UpdateSourceTrigger=PropertyChanged,
                                ValidatesOnDataErrors=True}"
                 TextWrapping="Wrap"
                 VerticalScrollBarVisibility="Auto" />



        <TextBlock Grid.Row="8"
                   Grid.Column="1"
                   Grid.ColumnSpan="7"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Center"
                   FontWeight="Bold"
                   Text="{Loc:Translate Address}" />

        <!--  Contacts  -->
        <TextBlock Grid.Row="10"
                   Grid.Column="1"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Center"
                   Text="{Loc:Translate City}" />
        <TextBox Grid.Row="10"
                 Grid.Column="3"
                 VerticalAlignment="Center"
                 MaxLines="1"
                 TabIndex="2"
                 Text="{Binding Path=City,
                                UpdateSourceTrigger=PropertyChanged}" />

        <TextBlock Grid.Row="10"
                   Grid.Column="5"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate ZIP}" />
        <TextBox Grid.Row="10"
                 Grid.Column="7"
                 VerticalAlignment="Center"
                 Behaviors:TextBoxBehavior.FilterInput="true"
                 Behaviors:TextBoxBehavior.InputFormat="{Loc:Translate _onlyNumbers_regex}"
                 MaxLength="5"
                 MaxLines="1"
                 TabIndex="3"
                 Text="{Binding Path=Zip,
                                UpdateSourceTrigger=PropertyChanged,
                                ValidatesOnDataErrors=True}" />



        <TextBlock Grid.Row="12"
                   Grid.Column="1"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Province}" />
        <TextBox Grid.Row="12"
                 Grid.Column="3"
                 VerticalAlignment="Center"
                 Behaviors:TextBoxBehavior.FilterInput="true"
                 Behaviors:TextBoxBehavior.InputFormat="{Loc:Translate _onlyLetters_regex}"
                 MaxLength="2"
                 MaxLines="1"
                 TabIndex="4"
                 Text="{Binding Path=Province,
                                UpdateSourceTrigger=PropertyChanged,
                                ValidatesOnDataErrors=True}" />

        <TextBlock Grid.Row="12"
                   Grid.Column="5"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Country}" />
        <!--  Agents  -->
        <!--
            <TextBlock Grid.Column="1"
            Grid.ColumnSpan="7"
            Grid.Row="29"
            FontWeight="Bold"
            HorizontalAlignment="Center"
            Text="Agents"
            VerticalAlignment="Center" />

            <TextBlock Grid.Column="1"
            Grid.Row="31"
            HorizontalAlignment="Right"
            Text="Agents"
            VerticalAlignment="Top" />
            <ListBox Grid.Column="3"
            Grid.ColumnSpan="5"
            Grid.Row="31"
            Height="118"
            Width="390"
            ItemsSource="{Binding Path=Agents}"
            SelectedItem="{Binding Path=SelectedAgent}"
            TabIndex="11">
            <ListBox.ItemTemplate>
            <DataTemplate>
            <DataTemplate:AgentDataTemplate />
            </DataTemplate>
            </ListBox.ItemTemplate>
            </ListBox>

            <StackPanel Grid.Column="3"
            Grid.ColumnSpan="5"
            Grid.Row="33"
            HorizontalAlignment="Left"
            Orientation="Horizontal">
            <Button Command="{Binding Path=AddAgentCommand, Mode=OneTime}"
            Content="Add agent"
            TabIndex="12"
            Width="80" />
            <Button Margin="8 0 0 0"
            Command="{Binding Path=EditAgentCommand, Mode=OneTime}"
            CommandParameter="{Binding Path=SelectedAgent, Mode=OneWay}"
            Content="Edit agent"
            TabIndex="13"
            Width="80" />
            <Button Margin="8 0 0 0"
            Command="{Binding Path=DeleteAgentCommand, Mode=OneTime}"
            CommandParameter="{Binding Path=SelectedAgent, Mode=OneWay}"
            Content="Delete agent"
            TabIndex="14"
            Width="80" />
            </StackPanel>
        -->

        <TextBox Grid.Row="12"
                 Grid.Column="7"
                 VerticalAlignment="Center"
                 MaxLines="1"
                 TabIndex="5"
                 Text="{Binding Path=Country,
                                UpdateSourceTrigger=PropertyChanged}" />

        <TextBlock Grid.Row="14"
                   Grid.Column="1"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Street}" />
        <TextBox Grid.Row="14"
                 Grid.Column="3"
                 VerticalAlignment="Center"
                 MaxLines="1"
                 TabIndex="6"
                 Text="{Binding Path=Street,
                                UpdateSourceTrigger=PropertyChanged}" />

        <TextBlock Grid.Row="14"
                   Grid.Column="5"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Number}" />
        <TextBox Grid.Row="14"
                 Grid.Column="7"
                 VerticalAlignment="Center"
                 MaxLines="1"
                 TabIndex="7"
                 Text="{Binding Path=Number,
                                UpdateSourceTrigger=PropertyChanged}" />

        <TextBlock Grid.Row="17"
                   Grid.Column="1"
                   Grid.ColumnSpan="7"
                   HorizontalAlignment="Center"
                   VerticalAlignment="Center"
                   FontWeight="Bold"
                   Text="{Loc:Translate Contacts}" />

        <TextBlock Grid.Row="19"
                   Grid.Column="1"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate AgentName}" />
        <TextBox Grid.Row="19"
                 Grid.Column="3"
                 TabIndex="8"
                 Text="{Binding AgentName}" />

        <TextBlock Grid.Row="19"
                   Grid.Column="5"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate AgentSurname}" />
        <TextBox Grid.Row="19"
                 Grid.Column="7"
                 TabIndex="9"
                 Text="{Binding AgentSurname}" />

        <TextBlock Grid.Row="21"
                   Grid.Column="1"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate AgentPhone}" />
        <TextBox Grid.Row="21"
                 Grid.Column="3"
                 TabIndex="10"
                 Text="{Binding AgentPhone}" />

        <TextBlock Grid.Row="25"
                   Grid.Column="1"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Phone}" />
        <TextBox Grid.Row="25"
                 Grid.Column="3"
                 VerticalAlignment="Center"
                 MaxLines="1"
                 TabIndex="11"
                 Text="{Binding Path=Phone,
                                UpdateSourceTrigger=PropertyChanged}" />

        <TextBlock Grid.Row="25"
                   Grid.Column="5"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Fax}" />
        <TextBox Grid.Row="25"
                 Grid.Column="7"
                 VerticalAlignment="Center"
                 MaxLines="1"
                 TabIndex="12"
                 Text="{Binding Fax,
                                UpdateSourceTrigger=PropertyChanged}" />

        <TextBlock Grid.Row="27"
                   Grid.Column="1"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Email}" />
        <TextBox Grid.Row="27"
                 Grid.Column="3"
                 VerticalAlignment="Center"
                 MaxLines="1"
                 TabIndex="13"
                 Text="{Binding Path=eMail,
                                UpdateSourceTrigger=PropertyChanged}" />



        <!--  Address  -->
        <TextBlock Grid.Row="27"
                   Grid.Column="5"
                   Margin="25,0,0,0"
                   HorizontalAlignment="Right"
                   VerticalAlignment="Top"
                   Text="{Loc:Translate Website}" />
        <TextBox Grid.Row="27"
                 Grid.Column="7"
                 VerticalAlignment="Center"
                 MaxLines="1"
                 TabIndex="14"
                 Text="{Binding Path=Website,
                                UpdateSourceTrigger=PropertyChanged}" />

        <StackPanel Grid.Row="29"
                    Grid.Column="1"
                    Grid.ColumnSpan="7"
                    HorizontalAlignment="Right"
                    Orientation="Horizontal">

            <Button Width="80"
                    Command="{Binding Path=ConfirmAddEditAndCloseCommand}"
                    Content="{Loc:Translate Ok}"
                    TabIndex="15">
                <Button.Margin>
                    <Thickness Right="{StaticResource View.MarginSize.Value}" />
                </Button.Margin>
            </Button>

            <Button Width="80"
                    Command="{Binding Path=CancelAddEditAndCloseCommand}"
                    Content="{Loc:Translate Cancel}"
                    IsCancel="True"
                    TabIndex="16" />

        </StackPanel>
    </Grid>
</UserControl>